package com.ck.jdbc.util;

import java.sql.ResultSet;
import java.sql.SQLException;

public class MyPoolTest {
	private static MyPoolImpl poolImpl = PoolManager.getInstace();

	public static void selectDate() {
		PooledConnection connection = poolImpl.getConnection();
		ResultSet res = connection.queryBySql("SELECT * FROM items");
		try {
			while (res.next()) {
				String id = res.getString("ID");
				String name = res.getString("NAME");
				String code = res.getString("CODE");
				System.out.print(id + "\t\t");
				System.out.print(name + "\t\t");
				System.out.print(code + "\t\t");
				System.out.println();
			}

			// 关闭
			res.close();
			connection.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		
		//selectDate();
		
		// 多线程同步，模拟10000
		for(int i = 0; i < 10000; i++) {
			new Thread(new Runnable() {
				
				@Override
				public void run() {
					selectDate();
				}
			}).start();
		}
	}
}
